﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Net.Mail;
using System.Net;
using ERP.Model.Base;
using ERP.BLL.Base;
using ERP.DAL;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc;

namespace ERP.Controllers
{
    public class BaseController : BasicsController
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            string ControllerInfo = RouteData.Values["controller"].ToString();
            string Action = RouteData.Values["action"].ToString();

            if (HttpContext != null)
            {
                if (string.IsNullOrEmpty(GetCookies("TBA_DID")))
                {
                    filterContext.Result = new RedirectResult("../home/Login");
                }
                else if (string.IsNullOrEmpty(GetCookies("TBE_DID")) && Action != "Enterprise")
                {
                    filterContext.Result = new RedirectResult("../Essential/Enterprise");
                }
            }

            base.OnActionExecuting(filterContext);
        }

    }
}